﻿using Engine;
using GameEntitySystem;
using TemplatesDatabase;

namespace Mekiasm.AnimateModel
{
    public class ComponentWindGenerate : ComponentMekModel
    {
        public Matrix? Rotate = null;
        public override void Animate()
        {
            if (!Rotate.HasValue) Rotate = Matrix.CreateTranslation(-0.5f, 0f, -0.5f) * Matrix.CreateRotationY(Direction / 2f * MathUtils.PI) * Matrix.CreateTranslation(m_componentFrame.Position.X, m_componentFrame.Position.Y, m_componentFrame.Position.Z) * Matrix.CreateTranslation(0.5f, 0f, 0.5f);
            SetBoneTransform(Model.RootBone.Index, Rotate);
            foreach (var c in ModelDatas)
            {
                if (c.MeshName.StartsWith("s"))
                {
                    //让扇叶旋转
                    var m = Matrix.CreateRotationZ(((Time.FrameIndex % 500) / 250f) * MathUtils.PI);
                    SetBoneTransform(c.Index, m);
                }
            }
        }
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            base.Load(valuesDictionary, idToEntityMap);
        }

    }
}
